<form id="component-form-step-2" class="" action="" lay-filter="component-form-step-2">
    {volist name="commParam.nodes" id="node1"}
    <div class="node-module">
        <label><input id="node_{$node1['id']}" name="nodes" type="checkbox" value="{$node1['id']}">{$node1['title']}</label>
        {volist name="node1.children" id="node2"}
        <div class="node-controller" style="text-indent: 2em;">
            <label><input id="node_{$node2['id']}" data-node-module="{$node1['id']}" name="nodes" type="checkbox" value="{$node2['id']}">{$node2['title']}</label>
            <div class="node-action" style="text-indent: 4em;">
            {volist name="node2.children" id="node3"}
                <label style="margin-right: 1em;"><input id="node_{$node3['id']}" data-node-module="{$node1['id']}" data-node-controller="{$node2['id']}" name="nodes" type="checkbox" value="{$node3['id']}">{$node3['title']}</label>
            {/volist}
            </div>
        </div>
        {/volist}
    </div>
    {/volist}
</form>
<script>
    layui.use(['upload','form'], function(){
        var upload = layui.upload;
        var $ = layui.jquery;
        var form = layui.form;

        var add_step2 = {
            gerNodes : function () {
                var result = [];
                $('[name="nodes"]').each(function () {
                    var $this = $(this);
                    if($this.prop('checked')){
                        result.push($this.val());
                    }
                });
                return result;
            },
            setNodes : function (nodes) {
                $('[name="nodes"]').prop('checked',false);
                for(var k in nodes){
                    $('#node_'+nodes[k]).prop('checked',true);
                }
            }
        };

        (function (add_step2) {

            // $('#component-form-step-2').on('change','[name="nodes"]',function (e) {
            //     var $this = $(e.target);
            //     var val = $this.val();
            //     var status = $this.prop('checked');
            //     var module = $this.attr('data-node-module');
            //     var controller = $this.attr('data-node-controller');
            //     if(module && controller){
            //         if(status){
            //             $('#node_'+controller).prop('checked',status);
            //             $('#node_'+module).prop('checked',status);
            //         }
            //     }else if(module){
            //         if(status){
            //             $('#node_'+module).prop('checked',status);
            //         }
            //     }
            // });

        })(add_step2);

        if(commParam['info'] !== null){
            // 编辑入参
            add_step2.setNodes(commParam['info']['nodes']);
        }

        window.add_step2 = add_step2;
    });
</script>